// packageI/pages/strageBill/strageBill.js
const app = getApp()
var applet_park_api_url = app.globalData.applet_park_api_url;
var applet_park_api_url_imgUrl = app.globalData.applet_park_api_url_imgUrl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: applet_park_api_url_imgUrl,
    token: wx.getStorageSync('TOKEN'),
    current: '',
    storeList: []
  },
  changeList(e) {
    var that = this
    that.data.current = e.currentTarget.dataset.type
    that.setData(that.data)
    that.getInfos()
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    that.getInfos()
  },

  getInfos() {
    var that = this
    wx.request({
      url: applet_park_api_url + '/api/consumableBillDetail/billDetailOrderFlow',
      method: 'GET',
      header: {
        Authorization: that.data.token
      },
      data: {
        billType: that.data.current
      },
      success: function (res) {
        if (res.data.code == 0) {
          console.log(res.data.data)
          for(var i in res.data.data){
            res.data.data[i].images = res.data.data[i].images.split(',')[0]
          }
          that.data.storeList = res.data.data
          that.setData(that.data)
        } else {
          wx.showToast({
            title: res.data.message,
            icon: 'none'
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})